package org.jash.sportnews2109.vm

import androidx.lifecycle.MutableLiveData
import org.jash.common.mvvm.BaseViewModel
import org.jash.common.retrofit
import org.jash.sportnews2109.net.APIService

class MineViewModel:BaseViewModel() {
    val service by lazy { retrofit.create(APIService::class.java)}
    val logoutLiveData by lazy { MutableLiveData<String>() }
    fun logout() {
        progress(service.logout()) {
            if (it.code == 0) {
                logoutLiveData.postValue("退出成功")
            } else {
                errorLiveData.postValue(RuntimeException(it.msg))
            }
        }
    }
}